﻿<%@ Page Title="Manage Behaviors" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeBehind="ManageBehaviors.aspx.cs" Inherits="NIntegrate.Configuration.UI.ManageBehaviors" ValidateRequest="false" MaintainScrollPositionOnPostback="true" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h2>Manage Behaviors</h2>
    <div class="bottomhyperlink"><img alt="Add new behavior" src="Images/plus.gif" /><asp:LinkButton 
            ID="btnShowAddNewPanel" runat="server" Text="Add new behavior" 
            onclick="btnShowAddNewPanel_Click"></asp:LinkButton></div>
    <br />
    <asp:GridView CssClass="gridview"
        ID="gvBehaviors" runat="server" 
        DataSourceID="dsBehaviors"
        DataKeyNames="Behavior_id"
        AllowSorting="true"
        AutoGenerateDeleteButton="true"
        AutoGenerateColumns="false"
        AutoGenerateEditButton="true" onrowcommand="gvBehaviors_RowCommand">
        <Columns>
            <asp:TemplateField HeaderText="BehaviorName" SortExpression="BehaviorName">
                <ItemTemplate>
                    <%#Eval("BehaviorName")%>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="tbBehaviorName" runat="server" MaxLength="100" Text='<%#Bind("BehaviorName") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="tbBehaviorNameRequired" runat="server"
                        ControlToValidate="tbBehaviorName" EnableClientScript="false"
                        ErrorMessage="Required"></asp:RequiredFieldValidator>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="BehaviorXML" SortExpression="BehaviorXML">
                <ItemTemplate>
                    <%# Eval("BehaviorXML") == null ? string.Empty : Server.HtmlEncode((string)Eval("BehaviorXML"))%>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="tbBehaviorXML" runat="server" Text='<%#Bind("BehaviorXML") %>' TextMode="MultiLine" Rows="3" Width="500px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="tbBehaviorXMLRequired" runat="server"
                        ControlToValidate="tbBehaviorXML" EnableClientScript="false"
                        ErrorMessage="Required"></asp:RequiredFieldValidator>                    
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Category" SortExpression="BehaviorCategory_id">
                <ItemTemplate>
                    <asp:DropDownList ID="ddlBehaviorCategories" runat="server" SelectedValue='<%# Bind("BehaviorCategory_id") %>' Enabled="false">
                        <asp:ListItem Text="Service" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Endpoint" Value="2"></asp:ListItem>
                    </asp:DropDownList>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:DropDownList ID="ddlBehaviorCategories" runat="server" SelectedValue='<%# Bind("BehaviorCategory_id") %>'>
                        <asp:ListItem Text="Service" Value="1"></asp:ListItem>
                        <asp:ListItem Text="Endpoint" Value="2"></asp:ListItem>
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>            
        </Columns>
        <SelectedRowStyle BackColor="LightYellow" />
    </asp:GridView>
    <asp:Panel ID="panelBottom" runat="server" CssClass="panelBottom">
        <asp:DetailsView ID="dvAddBehavior" runat="server" Visible="false"
            DataSourceID="dsBehaviors" DefaultMode="Insert"
            AutoGenerateRows="false"
            AutoGenerateInsertButton="true"
            CssClass="detailstable" onitemcommand="dvAddBehavior_ItemCommand" 
            oniteminserted="dvAddBehavior_ItemInserted">
            <HeaderTemplate>
                <h5>XML Templates:</h5>
                <a target="_blank" href="XmlTemplates/ServiceBehavior.xml">ServiceBehavior</a>
                <a target="_blank" href="XmlTemplates/EndpointBehavior.xml">EndpointBehavior</a>
            </HeaderTemplate>            
            <Fields>
                <asp:TemplateField HeaderText="BehaviorName">
                    <InsertItemTemplate>
                        <asp:TextBox ID="tbBehaviorName" runat="server" MaxLength="100" Text='<%#Bind("BehaviorName") %>'></asp:TextBox>
                        <asp:RequiredFieldValidator ID="tbBehaviorNameRequired" runat="server"
                            ControlToValidate="tbBehaviorName" EnableClientScript="false"
                            ErrorMessage="Required"></asp:RequiredFieldValidator>
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="BehaviorXML">
                    <InsertItemTemplate>
                        <asp:TextBox ID="tbBehaviorXML" runat="server" Text='<%#Bind("BehaviorXML") %>' TextMode="MultiLine" Rows="3" Width="500px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="tbBehaviorXMLRequired" runat="server"
                            ControlToValidate="tbBehaviorXML" EnableClientScript="false"
                            ErrorMessage="Required"></asp:RequiredFieldValidator>                    
                    </InsertItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Category">
                    <InsertItemTemplate>
                        <asp:DropDownList ID="ddlBehaviorCategories" runat="server" SelectedValue='<%# Bind("BehaviorCategory_id") %>'>
                            <asp:ListItem Text="Service" Value="1"></asp:ListItem>
                            <asp:ListItem Text="Endpoint" Value="2"></asp:ListItem>
                        </asp:DropDownList>
                    </InsertItemTemplate>
                </asp:TemplateField>
            </Fields>
        </asp:DetailsView>
    </asp:Panel>
    <ni:QueryDataSource ID="dsBehaviors" runat="server" UseLocalQueryService="true">
    </ni:QueryDataSource>
</asp:Content>
